package com.lanluo.service.sort;

import com.lanluo.service.stdlib.StdOut;

/**
 * @author
 * @date 2018-08-27-17:00
 */
public class Example {
    public static void sort(Comparable[] a) {

    }

    /**
     * 比较
     * @param v
     * @param w
     * @return
     */
    public static boolean less(Comparable v, Comparable w) {
        return v.compareTo(w) < 0;
    }

    /**
     * 交换位置
     * @param a
     * @param i
     * @param j
     */
    public static void exch(Comparable[] a, int i, int j) {
        Comparable t = a[i];
        a[i] = a[j];
        a[j] = t;
    }
    public static void show(Comparable[] a) {
        for (int i = 0; i < a.length; i++) {
            StdOut.print(a[i] + "");
            StdOut.println();
        }
    }

    public static boolean isSorted(Comparable[] a) {
        for (int i = 1; i < a.length; i++) {
            if(less(a[i], a[i-1])) return false;
        }
        return true;
    }

    public static void main(String[] args) {
        String[] a = {"S", "O", "R", "T"};
        sort(a);
        System.out.println(isSorted(a));
        show(a);
    }

}